﻿using System;

namespace IBBI.DataBase.Enumeration {

    public sealed class Role : IEquatable<Role> {

        public int    Value       { get; private set; }
        public string Name        { get; private set; }
        public string CName       { get; private set; }
        public string Description { get; private set; }

        public Role(int role, string name, string cname) {
            Value = role;
            Name  = name;
            CName = cname;
        }

        public bool Equals(Role other) {
            return Value == other.Value && Name.Equals(other.Name) 
                                        && CName.Equals(other.CName)
            ;
        }

        public override bool Equals(object obj) {
            if (obj == null) {
                return false;
            }
            if (ReferenceEquals(this, obj)) {
                return true;
            }
            if (obj is Role) {
                return Equals(obj as Role);
            }
            return false;
        }

        public override int GetHashCode() {
            unchecked {
                var hashCode = Value;
                hashCode = (hashCode * 397) ^ (Name  != null ? Name.GetHashCode()  : 0);
                hashCode = (hashCode * 397) ^ (CName != null ? CName.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0);
                return hashCode;
            }
        }
    }
}